package cn.hanyx.consumer;

import cn.hanyx.consumer.bean.Depart;
import org.modelmapper.ModelMapper;
import org.modelmapper.PropertyMap;

/**
 * ModelMapping
 *
 * @author hanyx
 * @date 2019/07/19
 */
public class ModelMapping {

    public static void main(String[] args) {
        ModelMapper modelMapper = new ModelMapper();
        modelMapper.addMappings(new PropertyMap<Depart, DepartDto>() {

            /**
             * Called by ModelMapper to configure mappings as defined in the PropertyMap.
             */
            @Override
            protected void configure() {
                map().setDeptName(source.getName());
                skip().setPassword(null);
            }
        });
        Depart depart = new Depart();
        depart.setId(1);
        depart.setName("hanyx");
        depart.setDbase("teste");
        DepartDto dto = modelMapper.map(depart, DepartDto.class);
        System.out.println(dto);
    }
}
